from appium import webdriver
from appium.webdriver.common.appiumby import By
from time import sleep
from zoom import *

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'D:\RJCS\Appium/minimap.apk'
desired_caps['appPackage'] = r'com.autonavi.minimap'
desired_caps['appActivity'] = r'com.autonavi.map.activity.SplashActivity'
desired_caps['noReset'] = False  # False代表重置（重新安装），默认值就是False


driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)  # 隐式等待
sleep(3)

# 点击 同意
try:
    ele = driver.find_element(By.ID, 'com.autonavi.minimap:id/agree')
except Exception as e:
    print('no cancelBtn')
else:
    ele.click()

# 点击 跳过
try:
    ele = driver.find_element(By.ID, 'com.autonavi.minimap:id/skip_btn')
except Exception as e:
    print('no cancelBtn')
else:
    ele.click()

# 点击 允许
try:
    ele = driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button')
except Exception as e:
    print('no notskip')
else:
    ele.click()

# 点击 允许
try:
    ele = driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button')
except Exception as e:
    print('no notskip')
else:
    ele.click()
# 点击 允许
try:
    ele = driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button')
except Exception as e:
    print('no notskip')
else:
    ele.click()

smaller(driver)
# bigger(driver)
sleep(5)

driver.quit()
